<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <link rel="StyleSheet" href="css/style.css" type="text/css">
  <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
  <meta name="verify-v1" content="sRQSq4VA5FRMhwzFB4U3I9AtgLMtIWTdpVVO6jg1az4=" />
  <title>AtomServer AutoTagger</title>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4603527-2");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body class="maincontent">
<h1><img src="images/atom-logo.gif" alt="logo">&nbsp;&nbsp;
<span style="font-weight: bold;"></span>AtomServer, Using the AutoTagger</h1>
<br>
<div class="content"><span style="font-style: italic;">Chris Berry,
Bryon Jacob. Updated 05/01/08</span><br>
<br>
This
document describes specific details about using the AtomServer
AutoTagger. <br>
<br>
For a further, detailed description of the actual protocol, either<br>
<ul>
  <li>See <a href="http://www.atomenabled.org/developers/syndication/">the
Atom Publishing Protocol Reference</a> for further information about
the
elements of the feed itself. Note that we do not exhaustingly document
this
information ourselves,&nbsp; because we are using Atom entirely as
dictated
by the standard.</li>
  <li>See <a href="atomserver_protocol_basics.html">the AtomServer
Protocol
Basics document </a>for general information about communicating with
the atomserver service.<br>
  </li>
</ul>
This document does <span style="font-weight: bold;">not</span> explain
the underlying concepts behind AtomServer; REST, Atom, and OpenSearch.
That
information can be found in <a href="atomserver_intro.html">the
AtomServer
General Introduction document</a>. <span style="font-style: italic;">It
is highly recommended that you read this document first</span>.<br>
<br>
Nor does this document explain the basics of XML,
namespaces, syndicated feeds, and the <span
 style="font-family: monospace;">GET, POST, PUT</span>, and <span
 style="font-family: monospace;">DELETE</span>
requests in HTTP, as well as HTTP's concept of a "resource." For more
information about those things, see the <a href="#resources">Additional
resources </a>section of
this document.<br>
<h2>Contents</h2>
<ul>
  <li><a href="#autotagging">Auto Tagging</a><br>
  </li>
  <li><a href="#resources">Additional Resources</a><br>
  </li>
</ul>
<hr style="width: 100%; height: 2px;">
<h2><span style="font-weight: bold;"><a name="autotagging"></a>Auto
Tagging </span></h2>
<h2><span style="font-weight: bold;"></span></h2>
AtomServer provides the ability to automatically applying Atom
Categories to entries as they are written to the ContenttStorage. This
is called "<span style="font-style: italic;">Auto tagging</span>".
AtomServer is built so that you can wire in any AutoTagger., you simply
implement the <span style="font-family: monospace;">EntryAutoTagger </span>interface.
But the most common AutoTagger is the built-in XPathAutoTagger.&nbsp;<span
 style="font-weight: bold;"></span>
<h3><span style="font-family: monospace;">XPathAutoTagger </span><br>
</h3>
<p>This <span style="font-family: monospace;">EntryAutoTagger</span>
implementation provides for tagging Entries based on matches against
XPATH expressions. </p>
<p> You can configure the <span style="font-family: monospace;">XPathAutoTagger</span>
in your Worksapce Bean in Spring in the straightforward manner - you
can set "namespaceMap" as a map from prefixes to namespace URIs, and
the "actions" property to a list of the inner classes on this class for
each of the actions that can be performed. They are: </p>
<p> </p>
<dl>
  <dt>delete all (<code>DeleteAllAction</code>)</dt>
  <dd>clears all of the categories for the entry</dd>
  <dt>delete scheme (<code>DeleteSchemeAction</code>)</dt>
  <dd>clears all of the categories in the given scheme for the entry</dd>
  <dt>match (<code>XPathMatchException</code>)</dt>
  <dd>evaluate an XPATH expression against the Entry Contents, and
write a category for each match </dd>
</dl>
when an XPATH expression is matched, the TEXT CONTENT of the nodes
matched (can be either elements or attributes) are stored in a variable
called $. Then, the termPattern is evaluated to set the category's
term, and the optional labelPattern is evaluated to set the label.
<p> To make configuration easier, this class defines a little scripting
language that can be set via the "script" bean property. Scripts are
defined by the following grammar (nonterminals in all caps, terminals
in title casing, character and string literals enclosed in single
quotes, and parentheses, asterisks, and question marks for grouping,
aggregation, and optional components. </p>
<pre> <b>nonterminals:</b><br> SCRIPT       ==&gt;     STATEMENT (';'* STATEMENT ';'*)*<br> STATEMENT    ==&gt;     NAMESPACE | DELETEALL | DELETESCHEME | MATCH<br> NAMESPACE    ==&gt;     'namespace' Prefix '=' Uri<br> DELETEALL    ==&gt;     'delete' 'all'<br> DELETESCHEME ==&gt;     'delete' ('scheme')? {Scheme}<br> MATCH        ==&gt;     'match' '"'Xpath'"' '{'Scheme'}' Termpattern ('['LabelPattern']')?<br> <b>terminals:</b><br> Prefix       ==&gt;     namespace prefix to use in XPATH expressions<br> Uri          ==&gt;     namespace URIs<br> Xpath        ==&gt;     the XPATH expression to match<br> Scheme       ==&gt;     category schemes<br> Termpattern  ==&gt;     the replacement pattern to use for generating category terms<br> Labelpattern ==&gt;     the replacement pattern to use for generating category labels<br></pre>
Keywords (delete, match, namespace, etc.) are not case sensitive. the
quoted string for the XPATH expression can contain double quotes if
they are escaped with backslash (i.e. \"). For example, a script could
look like:
<pre> NAMESPACE widgets = http://schemas.foo.com/widgets/v1/rev0;<br> DELETE SCHEME {urn:foo.brands};<br> MATCH "//widgets:brand" {urn:foo.brands}$;<br> MATCH "//widgets:brand[@isMaster='true']" {urn:foo.brands}MASTER:$[Entry has master brand $]<br> </pre>
<hr style="width: 100%; height: 2px;">
<h2><a name="resources"></a>Additional resources</h2>
You may find the following third-party documents useful:<br>
<br>
&nbsp;&nbsp;&nbsp; * <a
 href="http://www-128.ibm.com/developerworks/xml/library/x-atom10.html">Overview
of Atom</a> from IBM<br>
&nbsp;&nbsp;&nbsp; * <a
 href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html">HTTP 1.1
method definitions</a>; specification for GET, POST, PUT, and DELETE<br>
&nbsp;&nbsp;&nbsp; * <a
 href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">HTTP 1.1
status code definitions</a><br>
&nbsp;&nbsp;&nbsp; * <a
 href="http://www.atomenabled.org/developers/syndication/">Atom
Syndication Reference</a> (from Atom-enabled)<br>
&nbsp;&nbsp;&nbsp; * <a
 href="http://www-128.ibm.com/developerworks/library/x-atompp1/">Getting
to know the Atom Publishing Protocol (from IBM)</a><span
 style="font-weight: bold;"></span><br>
<br>
</div>
</body>
</html>
